package com.aaa.market.controller;

import com.aaa.common.util.Result;
import com.aaa.market.entity.AdvertisePosition;
import com.aaa.market.service.AdvertisePositionService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 广告位位置(AdvertisePosition)表控制层
 *
 * @author YuXin
 * @since 2020-11-25 15:40:31
 */
@RestController
@RequestMapping("advertisePosition")
public class AdvertisePositionController {
    /**
     * 服务对象
     */
    @Resource
    private AdvertisePositionService advertisePositionService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("queryById")
    public AdvertisePosition queryById(Object id) {
        return this.advertisePositionService.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param advertisePosition 模糊查询条件
     * @return 对象列表
     */
    @GetMapping("queryAll")
    public List<AdvertisePosition> queryAll(AdvertisePosition advertisePosition) {
        return this.advertisePositionService.queryAll(advertisePosition);
    }

    /**
     * 查询多条数据
     *
     * @return 对象列表
     */
    @PostMapping("queryAllByParam")
    public Result queryAllByParam(Integer pageNo, Integer pageSize, AdvertisePosition advertisePosition) {
        return this.advertisePositionService.queryAllByParam(pageNo, pageSize, advertisePosition);
    }

    /**
     * 查询多条数据
     *
     * @return 对象列表
     */
    @GetMapping("queryAllByParam")
    public Result queryAllByParamGet(Integer pageNo, Integer pageSize, AdvertisePosition advertisePosition) {
        return this.advertisePositionService.queryAllByParam(pageNo, pageSize, advertisePosition);
    }

    /**
     * 新增数据
     *
     * @param advertisePosition 实例对象
     * @return 实例对象
     */
    @PostMapping("insert")
    public AdvertisePosition insert(@RequestBody AdvertisePosition advertisePosition) {
        this.advertisePositionService.insert(advertisePosition);
        return advertisePosition;
    }

    /**
     * 修改数据
     *
     * @param advertisePosition 实例对象
     * @return 实例对象
     */
    @PutMapping("update")
    public AdvertisePosition update(@RequestBody AdvertisePosition advertisePosition) {
        return this.advertisePositionService.update(advertisePosition);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @DeleteMapping("deleteById")
    public boolean deleteById(Integer id) {
        return this.advertisePositionService.deleteById(id);
    }
}